Add tests for "doc --all"
authorSebastian Dröge <sebastian@centricular.com>
Sun, 8 Jan 2017 11:59:02 +0000 (13:59 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sun, 8 Jan 2017 12:01:09 +0000 (14:01 +0200)
These are basically the same as the ones from "test --all" and "build --all"

tests/doc.rs

index 44f2f4dff2373bde93da76c230968e2e3ea77c9c..e96eb0624839473843f9150f5cc422e8322e7cf7 100644 (file)
@@ -6,6 +6,7 @@ use std::fs;
 
 use cargotest::{is_nightly, rustc_host};
 use cargotest::support::{project, execs, path2url};
+use cargotest::support::registry::Package;
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
 #[test]
@@ -612,3 +613,97 @@ fn plugins_no_use_target() {
                  .arg("-v"),
                 execs().with_status(0));
 }
+
+#[test]
+fn doc_all_workspace() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+
+            [dependencies]
+            bar = { path = "bar" }
+
+            [workspace]
+        "#)
+        .file("src/main.rs", r#"
+            fn main() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", r#"
+            pub fn bar() {}
+        "#);
+    p.build();
+
+    // The order in which bar is compiled or documented is not deterministic
+    assert_that(p.cargo_process("doc")
+                 .arg("--all"),
+                execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
+                       .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
+                       .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])"));
+}
+
+#[test]
+fn doc_all_virtual_manifest() {
+    let p = project("workspace")
+        .file("Cargo.toml", r#"
+            [workspace]
+            members = ["foo", "bar"]
+        "#)
+        .file("foo/Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.1.0"
+        "#)
+        .file("foo/src/lib.rs", r#"
+            pub fn foo() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [project]
+            name = "bar"
+            version = "0.1.0"
+        "#)
+        .file("bar/src/lib.rs", r#"
+            pub fn bar() {}
+        "#);
+    p.build();
+
+    // The order in which foo and bar are documented is not guaranteed
+    assert_that(p.cargo_process("doc")
+                 .arg("--all"),
+                execs().with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
+                       .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])"));
+}
+
+#[test]
+fn doc_all_member_dependency_same_name() {
+    let p = project("workspace")
+        .file("Cargo.toml", r#"
+            [workspace]
+            members = ["a"]
+        "#)
+        .file("a/Cargo.toml", r#"
+            [project]
+            name = "a"
+            version = "0.1.0"
+
+            [dependencies]
+            a = "0.1.0"
+        "#)
+        .file("a/src/lib.rs", r#"
+            pub fn a() {}
+        "#);
+    p.build();
+
+    Package::new("a", "0.1.0").publish();
+
+    assert_that(p.cargo_process("doc")
+                 .arg("--all"),
+                execs().with_stderr_contains("[..] Updating registry `[..]`")
+                       .with_stderr_contains("[..] Documenting a v0.1.0 ([..])"));
+}